<html><body><pre>
<script>
Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
}
Array.method('map', 
    function(f) {
        var res = [];
        for (var i=0; i<this.length; i++) {
            res.push(f(this[i]));
        }
        return res;
    }
);
var v = [2, 4, 8];
document.writeln(
    v.map(
        function (x) {return x*10}
    )
);

</script>
</pre></body></html>
